package com.fanrenqiji.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import javax.persistence.*;


/**
 * Created by yanwt on 2017/1/3.
 * 教师信息表
 */
@Getter
@Setter
@Entity
@Table(name = "tb_teacher")
@org.hibernate.annotations.Table(appliesTo = "tb_teacher", comment = "教师信息表")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
@org.hibernate.annotations.Cache(region="teacher", usage = CacheConcurrencyStrategy.READ_WRITE)
public class TeacherEntity extends DataEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    @Column(columnDefinition = ("varchar(200) default null comment '头像'"))
    private String portrait;
    @Column(columnDefinition = ("int(1) not null comment '教师类型 0:未分类 1:班主任 2:辅导老师 3:全部'"))
    private int type; //类型
    @Column(columnDefinition = ("int(1) not null comment '状态 -1:锁定 0:未激活 1:激活 '"))
    private int status; //类型

    private String phone;
    private String password;

    @Column(name = "company_id", columnDefinition = ("bigint(20) not null comment '公司ID'"))
    private Long companyId;

    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "company_id", insertable = false, updatable = false, columnDefinition = ("bigint(20) not null comment '公司ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause = "del_flag=" + DEL_FLAG_NORMAL)
    private OfficeEntity office;

    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "we_chat_user_id", columnDefinition = ("bigint(20) default null comment '微信用户ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause = "del_flag=" + DEL_FLAG_NORMAL)
    private WeChatUserEntity weChatUser;

}
